import unittest

from api.manager import ManagerLitemall

from parameterized import parameterized

from data.manager_param import Data

from mysql.user_mysql import del_sql

from mysql.mysql_client import MySQLClient

lst_add = []


class TestManagerAdd(unittest.TestCase):
    mysql = None

    @classmethod
    def setUpClass(cls):
        cls.manager = ManagerLitemall()
        cls.mysql = MySQLClient()

    def setUp(self):
        self.mysql.execute(del_sql)

    @classmethod
    def tearDownClass(cls):
        cls.mysql.close()

    @parameterized.expand(Data.add_param_neg)
    def test_manager_add_neg(self, username, password, errno, errmsg):
        result = self.manager.add_manager(username, password)
        self.assertEqual(errno, result.get('errno'))
        self.assertEqual(errmsg, result.get('errmsg'))
